import React from 'react';
import { ImagePicker, WingBlank } from 'antd-mobile';
class ImagePickerExample extends React.Component {
    state = {
        files: [],
        multiple: false,
    }
    onChange = (files, type, index) => {
        console.log(files, type, index);
        this.setState({
            files,
        });
        this.props.getImg(files)
    }
    onSegChange = (e) => {
        const index = e.nativeEvent.selectedSegmentIndex;
        this.setState({
            multiple: index === 1,
        });
    }
    componentDidMount() {
        let files = this.props.date || []
        this.setState({
            files
        });
        this.props.getImg(files)
    }
    render() {
        let { files } = this.state;
        return (
            <WingBlank>
                <ImagePicker
                    files={files}
                    onChange={this.onChange}
                    onImageClick={(index, fs) => console.log(index, fs)}
                    selectable={files.length < 1}
                    multiple={this.state.multiple}
                />
            </WingBlank>
        );
    }
}
export default ImagePickerExample